<?php

namespace Drupal\shusy_plant_grass\MetadataController;

use Drupal\shusy_plant_grass\ViewsController\Traits\ShusyPlantGrassStatusTrait;
use Drupal\shusy_plant_grass\ViewsController\Traits\ShusyPlantGrassTypeTrait;
use EntityDefaultMetadataController;

class ShusyPlantGrassMetadataController extends EntityDefaultMetadataController {

  public function entityPropertyInfo() {
    $info = parent::entityPropertyInfo();
    $properties = &$info[$this->type]['properties'];
    $properties['user'] = [
      'label' => t('所有人'),
      'type' => 'user',
      'schema field' => 'uid',
      'description' => t('所有人.'),
    ];
    $properties['op_user'] = [
      'label' => t('操作人'),
      'type' => 'user',
      'schema field' => 'op_uid',
      'description' => t('操作人.'),
    ];

    $properties['created'] = [
      'label' => t('记录时间'),
      'type' => 'date',
      'schema field' => 'created',
      'description' => t('记录时间.'),
    ];
    $properties['changed'] = [
      'label' => t('变化时间'),
      'type' => 'date',
      'schema field' => 'changed',
      'description' => t('变化时间.'),
    ];

    $properties['status'] = [
      'label' => t('状态'),
      'description' => t('状态.'),
      'type' => 'integer',
      'options list' => [$this, 'getStatusOptions'],
      'required' => TRUE,
      'schema field' => 'status',
      'setter callback' => 'entity_property_verbatim_set',
    ];
    $properties['type'] = [
      'label' => t('类型'),
      'description' => t('类型.'),
      'type' => 'integer',
      'options list' => [$this, 'getTypeOptions'],
      'required' => TRUE,
      'schema field' => 'type',
      'setter callback' => 'entity_property_verbatim_set',
    ];
    return $info;
  }

  use ShusyPlantGrassStatusTrait, ShusyPlantGrassTypeTrait;
}
